package com.twotiger.and.activity.others;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;
import app.twotiger.p2p.R;

import com.twotiger.and.Constants;
import com.twotiger.and.activity.WebViewPage;
import com.twotiger.and.activity.base.BaseActivity;
import com.twotiger.and.bean.ConstantDataUnit;

public class ConmonQuestionPage extends BaseActivity implements OnClickListener {

    private static final int TUREMESSAGER = 0;
    private static final int ERRORMESSAGER = 1;
    private ImageView sub_title_left_bt;
    private TextView sub_title_center_tv;
    private TextView quest_text1;
    private TextView quest_text2;
    private TextView quest_text5;
    private TextView quest_text3;
    private TextView quest_text4;

    @Override
    protected View loadViewLayout(LayoutInflater inflater) {
        View view = inflater.inflate(R.layout.setting_layout, null);
        return view;
    }

    @Override
    protected void findViewById(View view) {
        quest_text1 = (TextView) view.findViewById(R.id.quest_text1);
        quest_text2 = (TextView) view.findViewById(R.id.quest_text2);
        quest_text5 = (TextView) view.findViewById(R.id.quest_text5);
        sub_title_left_bt = (ImageView) view.findViewById(R.id.sub_title_left_bt);
        quest_text3 = (TextView) view.findViewById(R.id.quest_text3);
        quest_text4 = (TextView) view.findViewById(R.id.quest_text4);
        sub_title_center_tv = (TextView) view.findViewById(R.id.sub_title_center_tv);
        sub_title_left_bt = (ImageView) view.findViewById(R.id.sub_title_left_bt);
    }

    @Override
    public void onClick(View view) {
        Intent intent = new Intent();
        switch (view.getId()) {
        case R.id.quest_text1:
            ConstantDataUnit dz_cjwt_tz = getConstantDataByKey(Constants.dz_cjwt_tz);
            if(dz_cjwt_tz != null){
                intent.setClass(mContext, WebViewPage.class);
                intent.putExtra("url", dz_cjwt_tz.getVal());
                intent.putExtra("title", dz_cjwt_tz.getName());
                startNewActivity(intent, R.anim.push_left_in, R.anim.push_left_out, false);
            }
            break;
        case R.id.sub_title_left_bt:
            onBackPress();
            break;
        case R.id.quest_text2:
            ConstantDataUnit dz_cjwt_cz = getConstantDataByKey(Constants.dz_cjwt_cz);
            if(dz_cjwt_cz != null){
                intent.setClass(mContext, WebViewPage.class);
                intent.putExtra("url", dz_cjwt_cz.getVal());
                intent.putExtra("title", dz_cjwt_cz.getName());
                startNewActivity(intent, R.anim.push_left_in, R.anim.push_left_out, false);
            }
            break;
        case R.id.quest_text3:
            ConstantDataUnit dz_cjwt_tx = getConstantDataByKey(Constants.dz_cjwt_tx);
            if(dz_cjwt_tx != null){
                intent.setClass(mContext, WebViewPage.class);
                intent.putExtra("url", dz_cjwt_tx.getVal());
                intent.putExtra("title", dz_cjwt_tx.getName());
                startNewActivity(intent, R.anim.push_left_in, R.anim.push_left_out, false);
            }
            break;
        case R.id.quest_text4:
            ConstantDataUnit dz_cjwt_zh = getConstantDataByKey(Constants.dz_cjwt_zh);
            if(dz_cjwt_zh != null){
                intent.setClass(mContext, WebViewPage.class);
                intent.putExtra("url", dz_cjwt_zh.getVal());
                intent.putExtra("title", dz_cjwt_zh.getName());
                startNewActivity(intent, R.anim.push_left_in, R.anim.push_left_out, false);
            }
            break;
        case R.id.quest_text5:
            ConstantDataUnit dz_cjwt_yhq = getConstantDataByKey(Constants.dz_cjwt_yhq);
            if(dz_cjwt_yhq != null){
                intent.setClass(mContext, WebViewPage.class);
                intent.putExtra("url", dz_cjwt_yhq.getVal());
                intent.putExtra("title", dz_cjwt_yhq.getName());
                startNewActivity(intent, R.anim.push_left_in, R.anim.push_left_out, false);
            }
            break;
        default:
            break;
        }
    }

    @Override
    protected void setListener() {
        quest_text1.setOnClickListener(this);
        quest_text2.setOnClickListener(this);
        quest_text3.setOnClickListener(this);
        quest_text4.setOnClickListener(this);
        quest_text5.setOnClickListener(this);
        sub_title_left_bt.setOnClickListener(this);
    }

    @Override
    protected void processLogic() {
        sub_title_left_bt.setVisibility(View.VISIBLE);
        sub_title_center_tv.setText("常见问题");
    }

    @Override
    protected void onBackPress() {
        finish();
        overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
    }

}
